{% extends "default/base.html" %}
{% load i18n uni_form_tags %}

{% block content %}

<ul class="breadcrumb">
   <li><a href="{% url market_home %}">{% trans "Home" %}</a><span class="divider"> / </span></li>
   <li><a href="{% url market_buy %}">{% trans "Buy" %}</a><span class="divider"> / </span></li>
   <li class="active">{% trans "Advanced Search" %}</li>
</ul>


<div class="span12 offset2" id="advanced-search">
    <h3>{% trans "Advanced Search" %}</h3>

   <form class="form-stacked" method="GET" action="{% url buy_advanced_search %}">
    {% uni_form form helper %}
</div>

<script type="text/javascript">
	$("#id_categories").click(function(){
		var selection = $(this).val();
		categories= new Array();
		categories.push(selection);
		
		$("#id_subcategories").empty();
	    
	    if (categories.length > 0) {
	      $.ajax({
	          url: "{% url ajax_get_subcategories %}", 
	          data: "categories=" + categories, 
	          success: function(data) {
		      	  $("#id_subcategories").append(data);
	          }
	      });
     	}
	});

    /* fire categories box's click event on document load event 
       so subcategories box get filled if there's a selected category
    */
    $(document).ready(function() {
       $("#id_categories").click();
       $("input[name='include'][value='description']").click();
       $("input[name='include'][value='title']").click();
       $("input[name='view_by'][value='gallery']").click();
       
    });
</script>


{% endblock %}
